package org.elephantt.webby;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class RedirectResponder implements Responder {
  public void respond(HttpServletRequest request, HttpServletResponse response, Object controllerReturnValue) throws IOException {
    Redirect redirect = (Redirect) controllerReturnValue;
    response.addHeader("Location", redirect.getLocation());
    response.setStatus(redirect.getType().getCode());
  }
}
